package com.example.administrator.basepro.base;

import com.example.administrator.basepro.App;
import com.example.administrator.basepro.dagger.component.ActivityComponent;
import com.example.administrator.basepro.dagger.component.DaggerActivityComponent;
import com.example.administrator.basepro.dagger.module.ActivityModule;

import javax.inject.Inject;

/**
 * Created by Administrator on 2017/8/31 0031.
 */

public abstract class BaseActivity<T extends BasePresenter> extends SimpleActivity implements BaseView {

    @Inject
    protected T mPresenter;

    protected ActivityComponent getActivityComponent(){
        return  DaggerActivityComponent.builder()
                .appComponent(App.getAppComponent())
                .activityModule(getActivityModule())
                .build();
    }

    protected ActivityModule getActivityModule(){
        return new ActivityModule(this);
    }



    @Override
    protected void onViewCreated() {
        super.onViewCreated();
        initInject();
        if (mPresenter != null)
            mPresenter.attachView(this);
    }

    @Override
    protected void onDestroy() {
        if (mPresenter != null)
            mPresenter.detachView();
        super.onDestroy();
    }



    @Override
    public void stateError() {

    }

    @Override
    public void stateEmpty() {

    }

    @Override
    public void stateLoading() {

    }

    @Override
    public void stateMain() {

    }
    protected abstract void initInject();


}
